<?php

namespace app\api\controller\setting;
use app\common\controller\BaseController;
use app\common\service\setting\SettingStoreTypeService;
use hg\apidoc\annotation as Apidoc;
/**
 * @Apidoc\Title("店铺类目")
 * @Apidoc\Group("setting")
 * @Apidoc\Sort("250")
 */
class SettingStoreType extends BaseController
{
    /**
     * @Apidoc\Title("选择店铺类目")
     * @Apidoc\Query(ref="sortQuery")
     * @Apidoc\Query(ref="searchQuery")
     * @Apidoc\Query(ref="dateQuery")
     * @Apidoc\Returned(ref="app\common\model\SettingStoreTypeModel", field="id,title")
     */
    public function select()
    {
        $param = $this->params(['type/d' =>null]);
        $where = $this->where(where_delete());
        $where[] = ['is_disable','=',0];
        $data = SettingStoreTypeService::getList($where, $this->order(),'id as value,title as label,code,is_disable as disable');
        if($param['type'] == 1){//追加一个全部
            array_unshift($data, ['value' =>0, 'label' => '全部','code' => 0]);
        }
        return success($data);
    }
}
